package com.withoutwords.ui.custom;

import com.withoutwords.R;

import android.content.Context;
import android.content.res.TypedArray;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageView;

public class DemoImageAdapter extends BaseAdapter
{
	public DemoImageAdapter(Context c)
	{
		mContext = c;
		TypedArray attr = mContext.obtainStyledAttributes(R.styleable.DemoGallery);
		// mGalleryItemBackground =
		// attr.getResourceId(R.styleable.HelloGallery_android_galleryItemBackground,
		// 0);
		attr.recycle();
	}
	
	public int getCount()
	{
		return mImageIds.length;
	}
	
	public Object getItem(int position)
	{
		return position;
	}
	
	public long getItemId(int position)
	{
		return position;
	}
	
	public View getView(int position, View convertView, ViewGroup parent)
	{
		ImageView imageView = new ImageView(mContext);
		
		imageView.setImageResource(mImageIds[position]);
		imageView.setScaleType(ImageView.ScaleType.FIT_XY);
		
		// imageView.setBackgroundResource(mGalleryItemBackground);
		
		return imageView;
	}
	
	/**
	 * global variables
	 */
	int mGalleryItemBackground;
	private Context mContext;
	
	private Integer[] mImageIds = { R.drawable.demo_page_1,
			R.drawable.demo_page_2,
			R.drawable.demo_page_3,
			R.drawable.demo_page_4,
			R.drawable.demo_page_5,
			R.drawable.demo_page_6,
			R.drawable.demo_page_7,
			R.drawable.demo_page_8 };
}
